import { axios } from '@/utils/request'

//post
export function postAction(url,parameter) {
    return axios({
        url: url,
        method:'post' ,
        data: parameter
    })
}

//post method= {post | put}
export function httpAction(url,parameter,method) {
    return axios({
        url: url,
        method:method ,
        data: parameter
    })
}

//put
export function putAction(url,parameter) {
    return axios({
        url: url,
        method:'put',
        data: parameter
    })
}

//get
export function getAction(url,parameter) {
    return axios({
        url: url,
        method: 'get',
        params: parameter
    })
}

//deleteAction
export function deleteAction(url,parameter) {
    return axios({
        url: url,
        method: 'delete',
        params: parameter
    })
}

/**
 * 下载文件 用于excel导出
 * @param url
 * @param parameter
 * @returns {*}
 */
export function downFile(url,parameter){
    return axios({
        url: url,
        params: parameter,
        method:'get' ,
        responseType: 'blob'
    })
}

export function queryPermissionsByUser(params){
  return axios({
    url: '/sys/permission/queryByUser',
    method: 'get',
    params: params
  })
}

export function login(parameter) {
  return axios({
    url: '/sys/login',
    method: 'post',
    data: parameter
  })
}

export function getInfo() {
  return axios({
    url: '/api/user/info',
    method: 'get',
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}

export function logout(logoutToken) {
  return axios({
    url: '/sys/logout',
    method: 'post',
    headers: {
      'Content-Type': 'application/json;charset=UTF-8',
      'X-Access-Token':  logoutToken
    }
  })
}